<html>
  <head>
	<meta charset="utf-8">
  </head>
  <body>
  <script>
	var blocks = {};
	function start(){
	    var doc = document.getElementById("i");
		var str = doc.value.split(" ");
		//for(x in str){alert(str[x]);}
		switch(str[0]){
		case "fill":
		fill(str);
		break;
		case "get":
		get(str);
		break;
		}
	    }
	function fill(str){
		//alert(JSON.stringify(blocks));
		var counter = 0;
		var sx = nan(str[1]);
		var sy = nan(str[2]);
		var sz = nan(str[3]);
		var ex = nan(str[4]);
		var ey = nan(str[5]);
		var ez = nan(str[6]);
	    for(var nx = sx;nx <= ex;nx++){
		    for(var ny = sy;ny <= ey;ny++){
			    for(var nz = sz;nz <= ez;nz++){
	                blocks[nx] = blocks[nx]||{};
					blocks[nx][ny] = blocks[nx][ny]||{};
				    blocks[nx][ny][nz] = str[7];
				    counter++;
					}
			    }
		    }
			document.getElementById("o").innerHTML = counter + "blocks has been placed";
		}
	function get(str){
	    try{
	    document.getElementById("o").innerHTML = "the block is " + blocks[str[1]][str[2]][str[3]];
		}catch(e){document.getElementById("o").innerHTML = "the block is air";};
		}
		//整数
	function nan(n){
	    n = Number.parseInt(n);
	    if(!Number.isInteger(n)){err("语法错误");throw "";}
		return n;
	    }
	function err(e){document.getElementById("e").innerHTML=e;}
  </script>
  <input type="text" id="i">
  <button onclick="start()">开始</button>
	<div id="o"></div>
	<div style="color:red" id="e"></div>
  </body>
</html>
